<template>
  <div class="building-container">
    <!-- 搜索区域 -->
    <div class="search-container">
      <el-button type="primary" @click="addQuyu">添加区域</el-button>
    </div>
    <el-dialog
      title="添加区域"
      :visible="dialogVisible"
      width="580px"
      @close="closeDialog"
    >
      <div class="form-container">
        <el-form ref="addForm" :model="addForm" :rules="addFormRules">
          <el-form-item label="区域名称" prop="areaName">
            <el-input v-model="addForm.areaName" placeholder="请输入区域" />
          </el-form-item>
          <el-form-item label="车位数（个）" prop="areaName">
            <el-input v-model="addForm.areaName" placeholder="请输入车位数（个）" />
          </el-form-item>
        </el-form>
      </div>
      <template #footer>
        <el-button size="mini" @click="dialogVisible = false">取 消</el-button>
        <el-button size="mini" type="primary" @click="dialogVisible = false">确 定</el-button>
      </template>
    </el-dialog>
    <!-- 表格区域 -->
    <div class="table">
      <el-table
        style="width: 100%"
        :data="libiaoList"
      >
        <el-table-column
          type="index"
          label="序号"
        />
        <el-table-column
          label="区域名称"
          width="180"
          prop="areaName"
        />
        <el-table-column
          label="车位数（个）"
          prop="spaceNumber"
        />
        <el-table-column
          label="面积（㎡）"
          width="120"
          prop="areaProportion"
        />
        <el-table-column
          label="计费规则"
          width="120"
          prop="hoverRuleName"
        />
        <el-table-column
          label="备注"
          width="120"
          prop="remark"
        />
        <el-table-column
          label="操作"
        >
          <template #default="scope">
            <el-button
              size="mini"
              type="text"
            >编辑</el-button>
            <el-button
              size="mini"
              type="text"
            >删除</el-button>
          </template>
        </el-table-column>
      </el-table>

    </div>
  </div>
</template>

<script>
import { getRuleListAPI } from '@/api/carquyu'
export default {
  name: 'Building',
  data() {
    return {
      libiaoList: [],
      dialogVisible: false,
      params: {
        page: 1,
        pageSize: 10
      },
      addForm: {
        areaName: ''
      },
      addFormRules: {
        areaName: [
          { required: true, message: '请输入一体杆名称', trigger: 'blur' }
        ]
      }

    }
  },
  mounted() {
    this.getRuleList()
  },
  methods: {
    async getRuleList() {
      const res = await getRuleListAPI()
      // console.log(res)
      this.libiaoList = res.data.rows
    },
    addQuyu() {
      this.dialogVisible = true
    },
    closeDialog() {
      this.dialogVisible = false
    }
  }
}
</script>

<style lang="scss" scoped>
.department-container{
  padding:10px;
}
.search-container{
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgb(237,237,237,.9);;
  padding-bottom: 20px;
  .search-label{
    width:100px;
  }
  .search-main{
    width: 220px;
    margin-right: 10px;
  }
}
</style>
